package com.zs.diveinspringbootkotlin.bootstrap

import com.zs.diveinspringbootkotlin.service.CalculateService
import org.springframework.boot.WebApplicationType
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.context.annotation.ComponentScan

/**
 *
 * @description
 * @author madison
 * @date 2021/6/3 19:55
 *
 */
@SpringBootApplication(scanBasePackages = ["com.zs.diveinspringbootkotlin.service"])
class CalculateServiceBootstrap

fun main(array: Array<String>) {
    val context = SpringApplicationBuilder(CalculateServiceBootstrap::class.java)
        .web(WebApplicationType.NONE)
        .profiles("Java8")
        .run(*array)

    var calculateService = context.getBean(CalculateService::class.java)
    println("calculateService.sum(1..10):${calculateService.sum(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)}")

    // 关闭上下文
    context.close()
}